using System.Collections.Generic;

namespace AndyPike.Unfuddle.XmlEntityClassGenerator
{
    class Class
    {
        public string XmlName { get; private set; }
        public string Name { get; private set; }
        public List<Property> Properties { get; private set; }

        public Class(string xmlName)
        {
            XmlName = xmlName;
            Name = SafeName(xmlName);
            Properties = new List<Property>();
        }

        public static string SafeName(string xmlName)
        {
            string name = string.Empty;
            xmlName = xmlName.ToLower();

            bool upperCase = true;
            for (int i = 0; i < xmlName.Length; i++)
            {
                string c = xmlName[i].ToString();

                if (c == "-")
                {
                    upperCase = true;
                    continue;
                }

                if(upperCase)
                    name += c.ToUpper();
                else
                    name += c;

                upperCase = false;
            }
            
            return name;
        }
    }
}